<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="__PUBLIC__/echarts/echarts.min.js"></script>
    <link rel="stylesheet" href="__PUBLIC__/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="__PUBLIC__/font-awesome/css/font-awesome.min.css" media="all">
    <link rel="stylesheet" href="__CSS__/admin.css"  media="all">
</head>
<style>

    .layui-table th, .layui-table td{
        padding: 9px 6px;
        text-align: center;
    }
    .operation-menu a{
        margin: 5px 0;!important;
    }
    #tooltip{
        position:absolute;
        border:1px solid #ccc;
        background:#333;
        padding:2px;
        display:none;
        color:#fff;
    }
    /*.layui-form select{*/
    /*display: inline-block;*/
    /*}*/
</style>
<body>
<div class="layui-fluid main">
    <fieldset class="layui-elem-field site-demo-button" style="margin-top: 30px;border:0">
        <div class="layui-form-item" style="float: left;">
            <form class="layui-form serch" action="{:url('admin/goods/index')}" method="post">
                <div class="layui-form-item" style="float: left;">

                    <a href="{:url('admin/Carousel/addimg')}" class="layui-btn layui-btn-sm a_menu">
                        上传图片
                    </a>

                </div>
            </form>

        </div>
    </fieldset>
    <table class="layui-table" lay-even="" lay-skin="line">
        <colgroup>
            <col width="10%">
            <col width="10%">
            <col width="10%">
            <col width="15%">
            <col width="15%">
            <col width="15%">
            <col width="15%">
            <col width="10%">
            <col width="15%">
        </colgroup>
        <thead>

        <tr>
            <th>图片编号</th>
            <th>名称</th>
            <th>略缩图</th>
            <th>连接路径</th>
            <th>是否显示</th>
            <th>合作商</th>
            <th>轮播排序</th>
            <th>显示终端</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        {volist name='img' id='vo'}
        <tr>
            <td>{$vo.id}</td>
            <td>{$vo.img_name}</td>
            <td>{if !empty($vo.img_src)}<a href="{$vo.img_src}" class="tooltip"><img src="{$vo.img_src}" width="20" height="20"></a>{/if}</td>
            <td >
                {$vo.img_src}
            </td>
            <td>
                <?php if($vo['show_hidden']=='0'){
                   echo "不显示";
                    }else{
                  echo '显示';
                    }?>
            </td>
            <td >
                {$vo.partner_name}
            </td>
            <td >
                {$vo.img_sort}
            </td>
            <td >
                <?php if($vo['terminal']==0){
                        echo '小程序';
                    }else if($vo['terminal']==1){
                     echo 'WAP端';
                    }  ?>
            </td>
            <td class="operation-menu">
                <a href="{:url('admin/Carousel/edit')}?id={$vo.id}" class="layui-btn layui-btn-xs layui-btn-warm a_menu"  style="margin-right: 0;font-size:12px;background: darkslategrey">编辑</a>
                {switch name="vo.show_hidden"}
                {case value="0"} <a href="####" class="layui-btn layui-btn-xs layui-btn-danger shelves" data-id="{$vo.show_hidden}"  codeid="{$vo.id}" style="margin-right: 0;font-size:12px;">显示</a>{/case}
                {case value="1"} <a href="####" class="layui-btn layui-btn-xs layui-btn-danger shelves" data-id="{$vo.show_hidden}" codeid="{$vo.id}" style="margin-right: 0;font-size:12px;">隐藏</a>{/case}
                {default /}default
                {/switch}
                <a href="####" class="layui-btn layui-btn-xs layui-btn-danger delete" codeid="{$vo.id}" style="margin-right: 0;font-size:12px;">删除</a>
            </td>
        </tr>
        {/volist}
        </tbody>
    </table>
    <div>{//$liebiao->render()}</div>

    <script src="__PUBLIC__/layui/layui.js"></script>
    <script src="__PUBLIC__/jquery/jquery.min.js"></script>

    <script>


        $(function(){
            var x = 10;
            var y = 20;
            $(".tooltip").mouseover(function(e){
                var tooltip = "<div id='tooltip'><img src='"+ this.href +"' alt='头像' height='200'/>"+"<\/div>"; //创建 div 元素
                $("body").append(tooltip);  //把它追加到文档中
                $("#tooltip")
                    .css({
                        "top": (e.pageY+y) + "px",
                        "left":  (e.pageX+x)  + "px"
                    }).show("fast");    //设置x坐标和y坐标，并且显示
            }).mouseout(function(){
                $("#tooltip").remove();  //移除
            }).mousemove(function(e){
                $("#tooltip")
                    .css({
                        "top": (e.pageY+y) + "px",
                        "left":  (e.pageX+x)  + "px"
                    });
            });
        })


        var message;
        layui.config({
            base: '__JS__/',
            version: '1.0.1'
        }).use(['app', 'message'], function() {
            var app = layui.app,
                $ = layui.jquery,
                layer = layui.layer;
            //将message设置为全局以便子页面调用
            message = layui.message;
            //主入口
            app.set({
                type: 'iframe'
            }).init();
        });
    </script>
    <script type="text/javascript">
        $('.shelves').click(function(){
            var id = $(this).attr('codeid');
            var show_hidden= $(this).attr('data-id');
            layer.confirm('是否确定操作？', function(index) {
                $.ajax({
                    url:"{:url('admin/Carousel/shelves')}",
                    data:{id:id,show_hidden:show_hidden},
                    success:function(res) {
                        layer.msg(res.msg);
                        if(res.code == 1) {
                            setTimeout(function(){
                                location.reload();
                            },1500)
                        }
                    }
                })
            })
        })


         $('.delete').click(function(){
             var id = $(this).attr('codeid');
             layer.confirm('确定删除吗?', function(index) {
                 $.ajax({
                     url:"{:url('admin/Carousel/delete')}",
                     data:{id:id},
                     success:function(res) {
                         layer.msg(res.msg);
                         if(res.code == 1) {
                             setTimeout(function(){
                                 location.reload();
                             },1500)
                         }
                     }
                 })
             })
         })

    </script>
    <script type="text/javascript">
        layui.use('layer', function(){
            var layer = layui.layer;
            $('.a_menu').click(function(){
                var url = $(this).attr('href');
                var a = 0;
                $.ajax({
                    url:url
                    ,async:false
                    ,success:function(res){
                        if(res.code == 0) {
                            layer.msg(res.msg);
                            a = 1;
                        }
                    }
                })
                if(a === 0) {
                    layer.open({
                        type:2,
                        content:url,
                        area: ['700px', '680px'],
                        end:function(){
                            location.reload();
                        }
                    });
                }
                return false;
            })

            $('.preview').click(function(){
                var url = $(this).attr('href');
                layer.open({
                    type:2,
                    content:url,
                    area: ['550px', '400px']
                });
                return false;
            })
        });
    </script>

</body>
</html>
